Verifies the fix in commit
2065c3909935 ("libubox: Drop extraneous space
when appending values to variable") that prevents leading spaces when
appending to empty variables.
test_jshn_append_no_leading_space
ASSERT:expected:<foo> but was:< foo>
ASSERT:expected:<first second> but was:< first second>
References: #16
Signed-off-by: Petr Štetiar <[email protected]>
%VAR% ow"
}
+test_jshn_append_no_leading_space() {
+ JSON_PREFIX="${JSON_PREFIX:-}"
+ . ../../sh/jshn.sh
+
+ # Test appending to empty variable - should not have leading space
+ var=''
+ _jshn_append var 'foo'
+ assertEquals "foo" "$var"
+
+ # Test appending to non-empty variable - should have space separator
+ var='bar'
+ _jshn_append var 'foo'
+ assertEquals "bar foo" "$var"
+
+ # Test multiple appends to empty variable
+ var=''
+ _jshn_append var 'first'
+ _jshn_append var 'second'
+ assertEquals "first second" "$var"
+}
+
. ./shunit2/shunit2